<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/4/6 0006
 * Time: 17:25
 */

namespace app\index\controller;


use think\Controller;

class Girls extends Controller
{
    public function index(){
        $m_id = session('member_id');
        if(!empty($m_id)){
            $member = db('member')->where('id',$m_id)->find();
            $this->assign('member',$member);
        }
        //现代言情
        $modernRomance = $this->modernRomance();
        //追更榜
        $moreList = $this->moreList();
        //古代言情
        $ancientRomance = $this->ancientRomance();
        //新书榜
        $newBook = $this->newBook();
        $footer = $this->footer();
        $banner = $this->banner();
//        dump($ancientRomance);die;
        $this->assign([
            'current' => 'girls',
            'modernRomance' => $modernRomance,
            'moreList' => $moreList,
            'ancientRomance' => $ancientRomance,
            'newBook' => $newBook,
            'footer' => $footer,
            'banner' => $banner
        ]);
        return view("index");
    }
    //现代言情
    public function modernRomance(){
        $data = model('girls')
            ->cache(true,360)
            ->where('title','现代言情')
            ->order('update','desc')
            ->with('book')
            ->limit(19)
            ->select();
        return $data;
    }
    //追更榜
    public function moreList(){
        $data = model('girls')
            ->cache(true,360)
            ->where('more_list',1)
            ->order('update','desc')
            ->with('book')
            ->limit(10)
            ->select();
        return $data;
    }
    //古代言情
    public function ancientRomance(){
        $data = model('girls')
            ->cache(true,360)
            ->where('title','古代言情')
            ->order('update','desc')
            ->with('book')
            ->limit(19)
            ->select();
        return $data;
    }
    //新书榜
    public function newBook(){
        $data = model('girls')
            ->cache(true,360)
            ->where('new_list',1)
            ->order('update','desc')
            ->with('book')
            ->limit(10)
            ->select();
        return $data;
    }
    public function footer(){
        $data = db("web") ->cache(true,600)->find();
        return $data;
    }
    //轮播
    public function banner(){
        //state == 2 的时候 轮播图为女生专区
        $banner = db("banner")
            ->where('state',2)
            ->cache(true,60)
            ->order('id', 'desc')
            ->limit(3)
            ->select();
        return $banner;
    }
}